<?php

namespace app\web\controller;

use app\common\HomeBase;
use Exception;
use support\Request;
use support\Response;

class Agreement extends HomeBase
{
    /**
     * @throws Exception
     */
    public function index(Request $request, $id = 0): Response
    {
        if (empty($id)) return $this->jump404();
        $info = \app\model\Agreement::getOne(['id' => $id]);
        if (empty($info)) return $this->jump404();
        return $this->homeTpl(compact('info'));
    }

    public function api(Request $request, $id = 0): Response
    {
        if (empty($id)) return $this->jump404();
        $info = \app\model\Agreement::getOne(['id' => $id]);
        if (empty($info)) return $this->jump404();
        return view('agreement/api', compact('info'));
    }
}
